package elka.sag.logisticsystem.actor;

import org.apache.log4j.Logger;

import elka.sag.logisticsystem.bean.Order;
import elka.sag.logisticsystem.message.SimpleMessage;

/**
 * Aktor do obslugi bledow z ktorymi inni aktorzy nie potrafili sobie poradzic
 * @author Wojtek
 *
 */
public class ErrorHandlerActor extends BaseActor {
	private final static Logger LOGGER = Logger.getLogger(ErrorHandlerActor.class);
	
	@Override
	protected void processMessage(SimpleMessage message) throws Exception {
		LOGGER.info(getClass().getSimpleName() + ": Bledne zamowienie, orderId: " + message.getOrderId());
		Order order = repositoryService.getOrderById(message.getOrderId());
		
		//zeby zamowienie nie bylo wiecej pobierane
		order.setProcess(true);
		//tylko zapisanie flagi czy_przetwarzane=1
		repositoryService.updateOrderStatusAndProcess(order);
	}

}
